﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
using Baimasoft.Manage.SqlServerDAL;

public partial class SysManage_User_Manage_Left : System.Web.UI.Page
{
    UserManage MyUM = new UserManage();
    public DataTable mytb;
    public DataColumn mycolumn;
    public string filedtotal = "";
    public string sHtml = "";
    public string sOrgCode = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            IniInfo("0","1");
        }
    }

    public void IniInfo(string sSOrgID, string Effective)
    {
        mytb = MyUM.GetUserGroupTree(Effective);
        foreach (DataColumn mycolumn in mytb.Columns)
        {
            filedtotal = filedtotal + mycolumn.ColumnName + ",";
        }
        sHtml = sHtml + "<script language=\"javascript\" type=\"text/javascript\">";
        filedtotal = filedtotal.Substring(0, filedtotal.Length - 1);
        sHtml = sHtml + " function tree(" + filedtotal + "){";
        string[] sfiledtotal = filedtotal.Split(',');
        int nfiledtotal = sfiledtotal.Length;
        for (int i = 0; i < nfiledtotal; i++)
        {
            sHtml = sHtml + "this." + sfiledtotal[i] + "=" + sfiledtotal[i] + ";";
        }

        if (mytb.Rows.Count > 0)
        {
            int iRowCount = mytb.Rows.Count - 1;
            sHtml = sHtml + "}var trees =new Array(" + iRowCount + ");";
        }
        else
        {
            sHtml = sHtml + "}var trees =new Array(0);";
        }

        for (int j = 0; j < mytb.Rows.Count; j++)
        {
            sHtml = sHtml + "trees[" + j + "] = new tree(";
            string temp = "";
            for (int k = 0; k < mytb.Columns.Count; k++)
            {
                temp = temp + "'" + mytb.Rows[j][k] + "'";
                if (k != mytb.Columns.Count - 1)
                {
                    temp = temp + ",";
                }
            }
            sHtml = sHtml + temp + ");";
        }
        sHtml = sHtml + "GetSuperOrgID('" + sSOrgID + "');show_tree(0,'0');SpreadNewOrgTree();";
        sHtml = sHtml + "</script>";
    }
}
